package com.bookstore.services.Impl;

import com.bookstore.mappers.UserMapper;
import com.bookstore.pojo.User;
import com.bookstore.services.UserService;
import com.bookstore.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserServiceImpl implements UserService {
    SqlSession sqlSession = SqlSessionUtil.getSqlSession();
    UserMapper mapper = sqlSession.getMapper(UserMapper.class);

    @Override
    public boolean registUser(User user) {
        return mapper.insert(user)>0;
    }

    /**
     * 登录
     * @param user
     * @return
     */
    public User login(User user){
        return mapper.selectUser(user);
    }

    @Override
    public List<User> selectUsers() {
        return mapper.selectAll();
    }


}
